package leetcode_core.leetcode_6;

/**
 * 功能描述
 *
 * @author: 张庭杰
 * @date: 2023年02月07日 16:08
 */
public class LongestConsecutive {
    class UF{
        private int[] parent;
        private int count;
        private int[] size;
        public UF(int n){
            //初始化
            parent = new int[n];
            count = n;
            for(int i = 0;i<n;i++){
                parent[i] = i;
                size[i] = 1;
            }
        }
        public boolean connected(int p,int q){
            int rootP = find(p);
            int rootQ = find(q);
            if(rootP == rootQ){
                return true;
            }
            return false;
        }

        public void union(int p,int q){
            int rootP = find(p);
            int rootQ = find(q);
            if(rootP == rootQ){
                return;
            }
            parent[rootQ] = rootP;
            size[rootQ] += size[rootP];
            this.count--;
        }

        public int find(int x){
            while(x!=parent[x]){
                parent[x] = find(parent[x]);
            }
            return x;
        }

        public int getMaxSize(){
            int maxSize = 0;
            for(int i = 0;i<size.length;i++){
                if(i == parent[i]){
                    maxSize = Math.max(maxSize,size[i]);
                }
            }
            return maxSize;
        }

    }

    public int longestConsecutive(int[] nums) {

        return 0;
    }


}
